Hi, I’m Brian, a former senior software engineer and now industry mentor at Pathrise. I have worked with hundreds of software engineers to help them land their dream jobs in tech. Check out this list of Java interview questions!
Java is one of the earliest successful programming languages and it is still widely used today. Software engineers, especially full-stack, should have a good grasp on Java as it is one of the top programming languages for those roles. So, if you are preparing to interview on a team that uses Java, you should practice by working on the Java interview questions you will likely be asked.
We created a list of 133 Java interview questions from real tech companies for you to practice. We have also included some tips that we found to be helpful in our experience helping hundreds of software engineers land great jobs.
Java interview questions
- Accenture question – Why is Java “platform independent”?
- LinkedIn question – What is a recursive function in Java?
- AMD question – How can you differentiate between C, C++, and Java?
- Pinterest question – What is runtime polymorphism?
- Apple question – How can you differentiate between method overloading and method overriding?
- ADP question – What is an interface in Java? Can we implement multiple interfaces in one class?
- Accenture question – Explain inheritance in Java? How can it be achieved?
- Microsoft question – Can we use multiple inheritance in Java? Explain why or why not.
- Google question – What can we do if we want to access a private member of a class?
- eBay question – What is the significance of the “static” keyword?
- LinkedIn question – What is “collection framework” in Java?
- Spotify question – What is the list interface in collections?
- Airbnb question – What do you understand about object cloning?
- Uber question – Can we insert duplicate values in a set?
- Accenture question – What is the “diamond problem” in Java? How can it be removed?
- Groupon question – What is the deadlock condition in multithreading?
- AMD question – Differentiate between collection and array.
- Airbnb question – What do you mean by “Java is a statically typed language”?
- Apple question – What is a lambda expression? Why is it used?
- Microsoft question – What is lazy initialization in hibernate?
- eBay question – Explain Flow of Spring MVC.
- Accenture question – What is the difference between a TreeMap and HashMap? What about between a HashMap and Hashtable?
- ADP question – Difference between public, private, default and protected?
- Google question – What is a final method?
- Pinterest question – What is casting?
- Groupon question – What is dependency injection or IOC (Inversion of Control)?
- Accenture question – What is a Final Variable?
- Groupon question – What is the use of the transient keyword?
- Airbnb question – What are various types of class loaders used by JVM?
- eBay question – What is an immutable class?
- Infosys question – How is polymorphism implemented in Java?
- Spotify question – What is the difference between stack and heap memory?
- AMD question – Write a program to check if a number is prime.
- Uber question – Explain the concept of inheritance.
- Infosys question – What is ‘null’ and how is memory allocation done for null objects?
- Google question – What is the difference between array and ArrayList?
- LinkedIn question – Write a program to swap two numbers in a list. Now write the same program without using a temporary variable. Is it possible?
- Apple question – What are the different modifiers in Java?
- Microsoft question – What is a class? How to create an object? If a class is static, can you create an object?
- ADP question – What are the different types of loops in Java?
- Infosys question – Why does a binary member function only accept a single argument?
- Groupon question – How can I get at the Dos File Handle associated with my Iostream?
- Amazon question – How do you merge two sorted linked lists?
- Google question – Write a program that checks if two strings are anagrams or not?
- Microsoft question – How do you find all pairs of elements in an integer array, whose sum is equal to a given number?
- Google question – Write a function to print nth number in fibonacci series.
- Pinterest question – Write a function to count a total number of set bits in a 32 bit Integer.
- Amazon question – Write an algorithm to check if a number is palindrome.
- Microsoft question – Write an algorithm to find out if array contains duplicates.
- eBay question – Write code to reverse a linked list. If you are able to do it using loops, try to solve with recursion.
- Amazon question – How do you rotate an array by a given pivot?
- Airbnb question – How do you remove duplicates from a sorted linked list?
- Microsoft question – How do you find the sum of digits of a number using recursion?
- Google question – Sort an array using selection sort.
- IBM question – What is the difference between abstract classes and interfaces?
- Google question – What is the difference between String, StringBuilder, and StringBuffer.
- AMD question – What is the difference between Final, Finally, and Finalize.
- Spotify question – What are custom exceptions?
- IBM question – What are web services? What are APIs? How do you create a REST API?
- LinkedIn question – What is the difference between object-oriented programming language and object-based programming language?
- Accenture question – What is abstraction and encapsulation in Java?
- Microsoft question – What is the life-cycle of a servlet?
- IBM question – What are threads?
- Groupon question – What is the difference between set and list?
- Pinterest question – What is the difference between iterator and ListIterator?
- AMD question – Differentiate between synchronized block and synchronized method?
- Google question – How do you handle the runtime exception in jsp?
- IBM question – How can you differentiate between java.util.date and java.sql.date?
- Microsoft question – I have 1 to 100 elements in an array unordered, one element is missed, can you find that element?
- eBay question – How can you differentiate between equals() and hashcode()?
- ACI Worldwide question – What is the difference between get() and load() in hibernate?
- Adobe question – Why is String immutable in Java?
- 23andMe question – Explain the difference between checked and unchecked exceptions?
More Java interview questions
- Spotify question – How do you define a functional interface?
- Accenture question – When do you use a vector?
- Spotify question – What is OSGI?
- Adobe question – What is the difference between Route53 alias and cname?
- Microsoft question – There is a server which is 90% full, I need to increase the space. How can I do it?
- Adobe question – What’s the difference between Java and C++? What about Java and Python?
- ADP question – What is the difference between == and .equals()?
- Google question – If you are given a choice to use either ArrayList and LinkedList, which one would you use and why?
- Apple question – What are the design considerations while making a choice between using interface and abstract class?
- ADP question – What are some different logging levels for log4j?
- Microsoft question – What is a cloneable interface and what all methods does it contain?
- LinkedIn question – What are the benefits of using prepared statements? Does that benefit extend only if similar prepared statements are used within an application or it extends even with multiple applications having similar prepared statements?
- ADP question – Where is the prepared statement object created – in Java application or DB?
- eBay question – What are the types of executor interfaces?
- Google question – What are the core interfaces in hibernate?
- ADP question – If two interfaces have the same method, how would you handle that method in a class implementing these two interfaces?
- Microsoft question – Which type of EJB can use bean pooling?
- Pinterest question – How can you differentiate between include directive and include action in jsp?
- Accenture question – How can you differentiate between import and include directive in jsp.
- Uber question – How can you differentiate between == and === ?
- ADP question – Where would you configure database details in tomcat server?
- Airbnb question – Write a method to check if an input string is palindrome.
- Amazon question – What is the difference between composition and inheritance in Java?
- Google question – Describe, in general, how Java’s garbage collector works.
- Amazon question – Design an e-commerce application using AWS. What AWS services will you use? What is the difference between AWS CloudFormation and AWS AMI?
- Amazon question – What is the difference between region, availability zone, and edge locations?
- Amazon question – What is the difference between S3 and EFS?
- Microsoft question – How can we protect from accidental deletes in S3?
- Apple question – What kind of access policy should be kept on S3 buckets?
- eBay question – What is the relationship between VPC and subnet? Can you explain with an example?
- ADP question – What is the difference between single instance web environment and load balanced auto scaling?
- Amazon question – What are the problems one could face while working with serverless technologies like AWS Lambda? How does AWS Lambda handle failure during event processing?
- Amazon question – What does AMI include?
- LinkedIn question – Why is cloud infrastructure so powerful?
- Spotify question – What are the advantages of having edge locations?
- Accenture question – What does effect, action, and resource mean with respect to AWS IAM policy?
- Uber question – How can we restrict CloudFront access to a particular geography?
- Amazon question – What is the use case for “on demand” EC2?
- Groupon question – What is the use case for “spot” in the EC2 plan?
- AMD question – What is the difference between overloading and overriding?
- Pinterest question – How do you find whether a given integer is odd or even without use of the modulus operator in Java?
- Google question – What is MVC?
- Apple question – What is reflection?
- Airbnb question – What is “fail fast” and “fail safe” in collections?
- Groupon question – Why doesn’t Java support multiple inheritance?
- AMD question – What is the use of HashCode in objects?
- Uber question – How are values passed in Java? By value or reference?
- ADP question – What is the purpose of commit and rollback in databases?
- Spotify question – What are exceptions and exception handling in Java?
- AMD question – What are the methods to connect to a database in Java?
- eBay question – Write a program to find the depth of a node binary tree.
- LinkedIn question – Talk about a time you utilized serialization in your project code?
- Google question – How do you analyze memory leaks in your Java application?
- Accenture question – Explain how a class is loaded?
- AMD question – What is the difference between map and filter methods in streams?
- Apple question – What is a deadlock?
- Pinterest question – What is the order of method invocation in an applet?
- Apple question – What is an applet? What is the lifecycle of an applet?
- eBay question – Develop a simple paint like program using applets.
- Avaya question – What are marker interfaces? Name a few Java marker interfaces.
At Pathrise, our industry mentors work with software engineers every day on their interview preparation and we see so many candidates who are ready technically, but they still struggle. We wanted to provide some extra tips to help you stay confident when you work through your Java interview questions.
- Start with clarifying questions
Before diving right into code, start by thinking of questions that you can ask that will clarify the problem and make sure you are on the same page as the interviewer. Some examples of these questions: “Are repetitions allowed?” or “Do you want to return permutations or combinations?”
- Tell the interviewer what you know
We always recommend that you provide short tidbits of knowledge to your interviewer as you go through the problem. This gives them a sense of what you know without having to ask you, which is what we call proactively showing positive signal. It also reduces awkward silences, especially in times when you are thinking and not coding.
- Make context statements as you work
While you work through the problem, clue the interviewer in to your thought process and decision-making. This gives them more insight into what you are doing and why. It is especially beneficial for them to have this window into your choices in case you make a mistake.
- Ask for help, not hints
It is ok to get help from the interviewer, though a lot of them won’t appreciate the word “hint.” Instead, collaborate with them on the issues you are having. For example, you can say, “my assumptions are X and Y, I’m thinking of doing Z. But I’m struggling with solving [problem].” You can also try questions like,
- I was wondering if you had any thoughts.
- Do you think I’m going down the right direction?
- Do you think my assumptions are incorrect?
With these Java interview questions & tips in your back pocket, you should be more than prepared for your next technical onsite interview. Feel like you need more help? Check out these resources to practice more software engineering interview questions.
You can also check out our other interview question lists:
- Python interview questions from top tech companies
- C# interview questions from top tech companies
- Javascript interview questions from top tech companies
- C interview questions from top tech companies
- Software engineer interview questions from top tech companies
Pathrise is a career accelerator that works with students and professionals 1-on-1 so they can land their dream job in tech. With these tips and guidance, fellows have seen their interview scores double.
If you want to work with any of our mentors 1-on-1 to get help with your software engineer interviews or with any other aspect of the job search, become a Pathrise fellow.